package cn.yunhe.servlet;

import cn.yunhe.bean.Ticket;
import cn.yunhe.biz.SceneryService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/TicketServlet")
public class TicketServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        SceneryService sceneryService = new SceneryService();
        List<Ticket>  ticketList = sceneryService.getTicketByuserid(id);

        int sum=sceneryService.getScenerySum();
        if(ticketList!=null&&ticketList.size()>0){
            request.setAttribute("sum",sum);
            request.setAttribute("ticketList",ticketList);
            request.getRequestDispatcher("ownTicket.jsp").forward(request,response);
        }
    }
}
